package com.zm.zmgz.controller;


import com.zm.zmgz.annotationzm.LoginRequired;
import com.zm.zmgz.pojo.Response;
import com.zm.zmgz.pojo.ShowEmployeesParamBean;
import com.zm.zmgz.service.AuthorityService;
import com.zm.zmgz.utils.ControllerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/page")
public class PageController { // 处理任意页面相关的请求

    @Autowired
    AuthorityService authorityService;

    /*
    * 功能:提供页面按钮权限标识;以身份证（身份证即为token，每个请求都会自带token）和 页面路径匹配path(string类型),以like匹配方式从authorityzm表中搜索，返回List<AuthorityBean>。遍历集合,处理path字段（截取最后的标识部分），得到该页面按钮的标识字符串(list<string>)，作为data属性对象返回。
    * */
    @LoginRequired // 需要登录
    @GetMapping("/getButtonAuthority")
    public Response getButtonAuthority(@RequestHeader("X-Token") String identificationNumber, String path){
        List<String> stringList = authorityService.getButtonAuthority(identificationNumber,path);
        System.out.println(identificationNumber+"获取"+path+"页面按钮权限数组:"+stringList);
        return new Response(20000,path+"页面按钮权限数组获取成功!",stringList);
    }







}
